<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ page import="crm.model.Material" %>
<%@ page import="crm.control.MaterialControl"%>
<%@page import="crm.control.SaleareaControl"%>
<%@ page import="crm.util.ParamUtil" %>
<%@ page import="java.util.*"  %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>常备资料</title>
     <script>
  	$(function(){
				//添加隔行换色
				$("tbody tr:odd").addClass("oddTR");
				
				// 添加鼠标经过样式
				$("tbody tr").mouseover(function(){
					$(this).addClass("mouseOverTR");
					$(this).children("td").each(function(){
						$(this).addClass("mouseOverTD");
						});
				});
					
				
				$("tbody tr").mouseout(function(){
					$(this).removeClass(["mouseOverTR"]);
					$(this).children("td").each(function(){
							$(this).removeClass(["mouseOverTD"]);
						});
					});
			})
			
  </script>
  </head>
  
  <body>
    <form>   
   <strong>常备资料</strong>
  <table>
 <thead>
     <tr>
  		
  		<th width="300">资料标题</th>
  		<th width="150">发布时间</th>
  		<th width="150">区域</th>
  		<th width="100">操作</th>
  		<th width="100">操作</th>
  </tr>
  </thead>
<tbody>
	<% 	
	    request.setCharacterEncoding("UTF-8");
 		session.removeAttribute("objectid");
 		int pages = ParamUtil.getInt(request, "pages", 1);
		int rowsPerPage = ParamUtil.getInt(request, "pageSize", 10);
		
		MaterialControl mc = new MaterialControl();
		Material material =new Material();
		 SaleareaControl sc = new SaleareaControl();
		List<Material> list = new ArrayList<Material>();
	   
	   list = (List) mc.getMaterial(pages, rowsPerPage);     

			for (int i = 0; i < list.size(); i++) {
				material = list.get(i);			
%>
	<tr>
 		
 		<td align = center><%=material.getMaterial_name()%></td> 		
 		<td align = center><%=material.getUpload_time()%></td>
 		<td align = center><%=sc.getAreaName(material.getSale_area_id())%></td>
 		<td align = center><a href = "material_update.jsp?id=<%=material.getId()%>">修改</a></td>
 		<td align = center>
 		<a href = "material_delete.jsp?id=<%=material.getId()%>" onclick='return confirm("确定要删除吗?")'>删除</a>
 		</td>
 	</tr>	

 		<%
				}
		%>
		</tbody>
   </table>
 	  <%
			out.println(MaterialControl.pageInstance.getToolsMenu(pages));
	  %>
	  
	   <input type = "button" value = "添加常备资料"
	  	onclick="window.location.href='material_add.jsp'" />	
	 </form>
  </body>
</html>
